package com.tigerCar.serviceOrder.server;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiger.order.pojo.ServiceOrder;
import com.tigerCar.serviceOrder.mapper.ServiceOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * chenzumao
 * 2021/4/21
 */
@Service
public class ServiceProviderService {
    @Autowired
    private ServiceOrderMapper serviceOrderMapper;

    public Page<ServiceOrder> allServiceOrder(Integer page, Integer pagesize) {
        IPage<ServiceOrder> orderIPage = new Page<>(page,pagesize);
        ServiceOrder serviceOrder =new ServiceOrder();
        QueryWrapper<ServiceOrder> query = Wrappers.query(serviceOrder);
        Page<ServiceOrder> pageResult = (Page<ServiceOrder>) serviceOrderMapper.selectPage(orderIPage, query);

        return pageResult;
    }

    /**
     * 创建订单
     * @param serviceOrder
     */
    public void createOrder(ServiceOrder serviceOrder) {
        if (serviceOrder != null) {
            int num = serviceOrderMapper.insert(serviceOrder);
            System.out.println("影响行数" + num);
        }
    }
}
